package com.tvunetworks.center.user.service;

import com.tvunetworks.center.common.model.LoginUser;
import com.tvunetworks.center.common.util.Result;
import com.tvunetworks.center.user.model.param.AddOrRemoveUserFeatureParam;
import com.tvunetworks.center.user.model.vo.UpdateUserFeatureVo;
import com.tvunetworks.center.user.model.vo.UserFeatureVo;

import java.util.List;
/**
 * @program:
 * @description:
 * @author HenryChen
 * @create: 5/29/2019 1:05 PM
 **/
public interface UserFeatureService {

    // 从 tvu_user_role 初始化到 tvu_user_feature
    /**
     * initUserFeature
     */
    @Deprecated
    void initUserFeature();

//    /**
//     * 查询用户所有feature
//     * @param userId
//     * @return
//     */
//    Map<String, List<UserFeatureVo>> listUserFeature(String userId);

    /**
     *
     * @param param param
     * @return int
     */
    int addOrRemoveFeature(AddOrRemoveUserFeatureParam param);

    /**
     * 根据roleId添加或删除feature或根据addFeatureIds/removeFeatureIds添加或删除feature
     * @param loginUser loginUser
     * @param param param
     * @return Result
     */
    Result<Object> addOrRemoveFeature(LoginUser loginUser, AddOrRemoveUserFeatureParam param);

    /**
     *
     * @param userId userId
     * @param featureId featureId
     * @return boolean
     */
    boolean isUserExistFeature(String userId, String featureId);

    /**
     *
     * @param userId userId
     * @param feature feature
     * @return  boolean
     */
    boolean isUserExistFeatureName(String userId, String feature);

    /**
     * tvucc 修改UserRole同步到UserFeature
     * @param userId userId
     * @param feature feature
     * @param enable enable
     */
    void apiUpdateUserRole(String userId, String feature, Integer enable);

    /**
     *
     * @param featureId featureId
     */
    void removeUserFeatureByFeatureId(String featureId);

    /**
     *
     * @param loginUser loginUser
     * @param targetUserRole targetUserRole
     * @return Result
     */
    Result<UpdateUserFeatureVo> listFeatureForCreate(LoginUser loginUser, String targetUserRole);

    /**
     *
     * @param loginUser loginUser
     * @param modifyUserId modifyUserId
     * @return Result
     */
    Result<UpdateUserFeatureVo> listFeatureForModify(LoginUser loginUser, String modifyUserId);

    /**
     * 列出用户所有拥有的featureIds，包含adminAutoOwn的feature，也包含autoOwn的menu
     * @param userId userId
     * @return List
     */
    List<String> listAllUserEnableFeatureIds(String userId);

    /**
     *
     * @param name name
     * @return Result
     */
    Result<Object> initAllHome(String name);


    /**
     *
     * 通过用户的id和feature 的名称查询用户是否拥有该权限
     *
     * @param userId 用户的 id
     * @param featureName feature 名称,例如: stopLive,startLive,setting 等
     *
     * @return false 不拥有该权限,true 拥有该权限
     */
    boolean userHasFeature(String userId,String featureName);

    /**
     *
     * @param userId userId
     */
    void removeUserAllFeature(String userId);

    /**
     * 给user账号批量添加和删除feature
     * @param userId userId
     * @param userRole userRole
     * @param userParentId userParentId
     * @param addFeatureIds addFeatureIds
     * @param removeFeatureIds removeFeatureIds
     */
    void addAndRemoveFeatureListByUserId(String userId, String userRole, String userParentId, List<String> addFeatureIds, List<String> removeFeatureIds);

    /**
     *  查询UserId拥有的权限
     * @param userId userid
     * @return 权限列表
     */
    List<UserFeatureVo> listFeatureByUserId(String userId);

    /**
     * 给用户授权Grid_Schedule权限
     * @return null
     */
    Result accreditAllUser();

    /**
     * 根据主键Id删除tvu_user_feature信息
     * @param id 主键id
     * @return null
     */
    Result deleteUserFeatureById(List<String> id);
}
